﻿/*   
    Copyright (C) 2009 Galaktika Corporation ZAO

    This file is a part of Galaktika.BusinessMonitor
 
    Galaktika.BusinessMonitor is a free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
      
    You should have received a copy of the GNU General Public License
    along with Galaktika.BusinessMonitor.  If not, see <http://www.gnu.org/licenses/>.
  
    If GPL v.3 is not suitable for your products or company,
    Galaktika Corp provides Galaktika.BusinessMonitor under a flexible commercial license
    designed to meet your specific usage and distribution requirements.
    If you have already obtained a commercial license from Galaktika Corp,
    you can use this file under those license terms.
*/

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Galaktika.BI.Runtime;
using Galaktika.BI.Runtime.Services;
using Galaktika.BI.Silverlight.Controls.General;
using Galaktika.BI.Silverlight.Controls.PivotGrid;
using Ranet.AgOlap.Controls.General;
using Ranet.AgOlap.Controls.PivotGrid.Controls;

namespace Galaktika.BI.Silverlight.Controls
{
    public class PivotTableHolder : UpdateablePivotGridControlEx
    {
        public PivotTableHolder()
        {
            base.AColumnsIsInteractive = false;
            base.ARowsIsInteractive = false;
            base.UseNavigationButtons = false;            
            
        }
       
        protected override void MemberActionCompleted(DataLoaderEventArgs e)
        {
        }

        //public static DependencyProperty ADataSourceProperty = DependencyProperty.Register("ADataSource", typeof(object), typeof(UpdateablePivotGridControl), null);
        //private object m_DataSource;
        //public object ADataSource
        //{
        //    get
        //    {
        //        return m_DataSource;
        //    }
        //    set
        //    {
        //        m_DataSource = value;
        //        PivotDataLoaderEx loader = base.Loader as PivotDataLoaderEx;
        //        if (loader != null)
        //        {
        //            IBindingManager manager = null;
        //            this.Bindings.TryGetValue("ADataSource", out manager);
        //            loader.BindManager = manager;
        //        }
        //    }
        //}


        protected override void PerformMemberAction(MemberActionEventArgs e)
        {
        }

        protected override void CellsControl_ContextMenuCreated(object sender, EventArgs e)
        {
            base.PivotGrid.Cells_ContextMenu.Items.Clear();
            //base.CellsControl_ContextMenuCreated(sender, e);

            //CustomContextMenu contextMenu = base.ScrollableDataControl.PivotGrid.CellsControl.ContextMenu;
            //if (contextMenu != null)
            //{
            //    if (ACellsAreaContextActions != null && ACellsAreaContextActions.Count > 0)
            //    {
            //        if (contextMenu.Items.Count > 0)
            //        {
            //            contextMenu.AddMenuSplitter();
            //        }

            //        foreach (ActionInfo info in ACellsAreaContextActions)
            //        {
            //            ContextMenuItem item = new ContextMenuItem(info.ACaption);
            //            item.ItemClick += new EventHandler(CellsAreaContextMenu_ItemClick);
            //            item.Tag = info;
            //            item.Icon = UriResources.Images.ActionNode16;
            //            contextMenu.AddMenuItem(item);
            //        }
            //    }

            //}
        }


        protected override void ColumnsControl_ContextMenuCreated(object sender, EventArgs e)
        {
            base.PivotGrid.Columns_ContextMenu.Items.Clear();
            //base.ColumnsControl_ContextMenuCreated(sender, e);

            //CustomContextMenu contextMenu = base.ScrollableDataControl.PivotGrid.ColumnsControl.ContextMenu;
            //if (contextMenu != null)
            //{
            //    if (AColumnsAreaContextActions != null && AColumnsAreaContextActions.Count > 0)
            //    {
            //        if (contextMenu.Items.Count > 0)
            //        {
            //            contextMenu.AddMenuSplitter();
            //        }

            //        foreach (ActionInfo info in AColumnsAreaContextActions)
            //        {
            //            ContextMenuItem item = new ContextMenuItem(info.ACaption);
            //            item.ItemClick += new EventHandler(ColumnsAreaContextMenu_ItemClick);
            //            item.Tag = info;
            //            item.Icon = UriResources.Images.ActionNode16;
            //            contextMenu.AddMenuItem(item);
            //        }
            //    }
            //}
        }

        protected override void RowsControl_ContextMenuCreated(object sender, EventArgs e)
        {
            base.PivotGrid.Rows_ContextMenu.Items.Clear();
            //base.RowsControl_ContextMenuCreated(sender, e);

            //CustomContextMenu contextMenu = base.ScrollableDataControl.PivotGrid.RowsControl.ContextMenu;
            //if (contextMenu != null)
            //{
            //    if (ARowsAreaContextActions != null && ARowsAreaContextActions.Count > 0)
            //    {
            //        if (contextMenu.Items.Count > 0)
            //        {
            //            contextMenu.AddMenuSplitter();
            //        }

            //        foreach (ActionInfo info in ARowsAreaContextActions)
            //        {
            //            ContextMenuItem item = new ContextMenuItem(info.ACaption);
            //            item.ItemClick += new EventHandler(RowsAreaContextMenu_ItemClick);
            //            item.Tag = info;
            //            item.Icon = UriResources.Images.ActionNode16;
            //            contextMenu.AddMenuItem(item);
            //        }
            //    }
            //}
        }



        #region IBindableObject Members

        //IBindingContext m_Context = null;
        //public IBindingContext Context
        //{
        //    get
        //    {
        //        return m_Context;
        //    }
        //    set
        //    {
        //        m_Context = value;
        //        if (m_Context != null)
        //        {
        //            base.LogManager = new LogManagerEx(m_Context);
        //        }
        //        PivotDataLoaderEx loader = base.Loader as PivotDataLoaderEx;
        //        if (loader != null)
        //        {
        //            loader.Context = value;
        //        }
        //        if (m_Context != null)
        //        {
        //            base.IsolatedStoragePrefix = (string)m_Context.UserData["_$Id"];
        //        }
        //        else
        //        {
        //            base.IsolatedStoragePrefix = String.Empty;
        //        }
        //    }
        //}

        //private IDictionary<string, IBindingManager> m_Bindings;
        //public IDictionary<string, IBindingManager> Bindings
        //{
        //    get
        //    {
        //        if (m_Bindings == null)
        //        {
        //            m_Bindings = new SafeDictionary<string, IBindingManager>();
        //        }

        //        return m_Bindings;
        //    }
        //}

        #endregion

        #region IEditableObject Members

        //public void BeginEdit()
        //{
        //   base.EndEdit();
        //}

        //public void CancelEdit()
        //{
        //}

        //public void EndEdit()
        //{
        //    base.EndEdit();
        //}

        #endregion

        //protected override void Initialize(CellSetData cs_descr)
        //{
        //    //IUserTaskManager taskManager = (IUserTaskManager)Context.Services.GetService(typeof(IUserTaskManager));
        //    //if (taskManager != null)
        //    //{
        //    //    taskManager.RunTask(Localization.AppTask_InitializingPivotGrid, delegate { CallBase_Initialize(cs_descr); });
        //    //    return;
        //    //}
        //    CallBase_Initialize(cs_descr);
        //}      

    }
}
